package file;

import java.io.File;

public class FileLength {

	public static long getFileSize(File f) {
		long sum = 0;
		// sum += f.length();

		if (f.isDirectory()) {
			File[] fs = f.listFiles();
			for (File f1 : fs) {
				if (f1.isDirectory()) {
					sum += getFileSize(f1);
				} else {
					sum += f1.length();
				}
			}
		}
		return sum;

	}

	public static void main(String[] args) {
		File f = new File("E:\\资料");
		System.out.println(getFileSize(f));
		// System.out.println(f.length());
		// System.out.println(f.canRead());
		// 574,616,136
		// 575,324,744
	}

}
